<div class="modal-header">
  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
  <h4 class="modal-title"><%= sails.__('private.index.userpassword') %></h4>
</div>
<div class="modal-body">
  <form id="passForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
        action="/private/sys/user/doChangePassword" method="post">
    <div class="row" style="padding-top: 10px;">
      <div class="col-lg-12">
        <div class="form">
          <label for="password" class="col-sm-2 control-label">原密码</label>

          <div class="col-sm-8">
            <input id="oldPassword" tabindex="1" type="password" class="form-control" name="oldPassword"
                   data-parsley-required="true" placeholder="原密码">
          </div>
        </div>
      </div>
    </div>
    <div class="row" style="padding-top: 10px;">
      <div class="col-lg-12">
        <div class="form">
          <label for="password" class="col-sm-2 control-label">新密码</label>
          <div class="col-sm-8">
            <input id="newPassword" tabindex="2" type="password" class="form-control" name="newPassword"
                   data-parsley-required="true" data-parsley-minlength="6" data-parsley-maxlength="20"  placeholder="新密码">
          </div>
        </div>
      </div>
    </div>
    <div class="row" style="padding-top: 10px;">
      <div class="col-lg-12">
        <div class="form">
          <label for="passwordAgain" class="col-sm-2 control-label">确认密码</label>

          <div class="col-sm-8">
            <input id="passwordAgain" type="password" tabindex="6" class="form-control"
                   data-parsley-equalto="#newPassword"
                   data-parsley-required="true" name="eqPassword" placeholder="请再输入一次密码">
          </div>
        </div>
      </div>
    </div>

  </form>
</div>
<div class="modal-footer">
  <button type="button" class="btn btn-default" data-dismiss="modal">取 消</button>
  <button type="button" id="okPwd" class="btn btn-primary">确 认</button>
</div>
<script type="text/javascript">
  $(function () {
    $("#okPwd").on("click",function(){
      $("#passForm").submit();
    });
    $("#passForm").ajaxForm({
      dataType: 'json',
      beforeSubmit: function (arr, form, options) {
        form.find("button:submit").text("提交...");
        form.find("button:submit").attr("disabled", "disabled");
      },
      success: function (data, statusText, xhr, form) {
        if (data.code == 0) {
          $('#homeDetail').modal('hide');
          Toast.success(data.msg);
          form.find("button:submit").text("确 认");
        } else {
          form.find("button:submit").text("确 认");
          form.find("button:submit").removeAttr("disabled");
          Toast.error(data.msg);
        }

      }
    });
  });
</script>
